package com.siashan.unipay4j.core.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 请求工具类
 *
 * @author siashan
 * @since v1.0.1
 **/
public class RequestUtil {


    /**
     * 解析body请求报文
     *
     * @param in   请求输入流
     * @return 字符串报文
     * @throws IOException
     */
    public static String getStrFromInputSteam(InputStream in) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(in, "UTF-8"));
        //最好在将字节流转换为字符流的时候 进行转码
        StringBuffer buffer = new StringBuffer();
        String line = "";
        while ((line = bf.readLine()) != null) {
            buffer.append(line);
        }
        return buffer.toString();
    }
}
